package com.rtx.wms.std.job.storer;

import com.rtx.edi.model.api.bo.ApiMappingInfoBo;
import com.rtx.edi.platform.baseinfo.service.PlApiService;
import com.rtx.wms.std.common.bean.Storer;
import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.common.service.CommonService;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.rtx.api.annotation.RtxJobAnnotation;
import com.rtx.api.quartz.job.BaseJob;
import com.rtx.wms.std.storer.handle.StorerSchedulerHandle;

import java.util.List;

@Component
@DisallowConcurrentExecution
@RtxJobAnnotation(jobName = "storertowmsjob",description = "贸易伙伴同步到仓库级",cron = "0/30 * * * * ?")
public class StorerToWmsJob implements BaseJob {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private StorerSchedulerHandle storerSchedulerHandle;

    @Autowired
    private CommonService commonService;

    @Autowired
    PlApiService plApiService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap dataMap = context.getJobDetail().getJobDataMap();

        String mappingCode = dataMap.get("apiMappingCode")+"";

        ApiMappingInfoBo bo = plApiService.getApiMappingInfo(mappingCode);

        List<Storer> list = storerSchedulerHandle.queryStorer(WmsConstant.ENTERPRISE,bo);
        storerSchedulerHandle.handle(list);
    }

//    @Override
//    public void execute(JobExecutionContext context) throws JobExecutionException {
//    	storerSchedulerHandle.handle();
//    }
}
